package com.common.util;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

/**
 * @author: stefanie-zy
 * @time: 2024/1/25-10:17
 * @description: 加密工具类
 */
@Schema(name = "工具-加解密")
public class EncryptionUtil {

    @Operation(summary = "字符串加密", description = "简单加密")
    public static String encrypt(String str) {
        return Base64.getEncoder().encodeToString(str.getBytes(StandardCharsets.UTF_8));
    }

    @Operation(summary = "字符串解密", description = "简单解密")
    public static String decode(String str) {
        return new String(Base64.getDecoder().decode(str.getBytes(StandardCharsets.UTF_8)));
    }
}
